package br.unisul.redeNeural;

import java.text.DecimalFormat;
import java.text.ParseException;

import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

public class TesteDefaultCalculoSaida {

	private DefaultCalculoSaida calculoSaida ;
	private Neuronio neuronios[];
	private Peso pesos[];
	private Neuronio responsavel;
	
	private double vlNeuronios [];
	private double vlPesos [];
	
	
	
	@Before
	public void setUP(){
		vlNeuronios = new double[]{1,-1,1-1,1,-1};
		vlPesos = new double[]{0.5,.9,.6,.7,1,.8};
	}
	
	@Test
	public void primeiroTeste(){
		calculoSaida = new DefaultCalculoSaida();
		neuronios = new Neuronio[vlNeuronios.length];
		pesos = new Peso[neuronios.length];
		for (int i = 0; i < neuronios.length; i++) {
			neuronios[i] = new NeuronioIntermediario(vlNeuronios[i]);
			pesos[i] = new Peso(vlPesos[i]);
		}
		responsavel = new NeuronioSaida(1);
		calculoSaida.calcularSaidaNeuronio(neuronios, pesos, responsavel);
		DecimalFormat df = new DecimalFormat("#,##0.#");
		double d;
		try {
			d = df.parse(df.format(responsavel.getValorNeuronio())).doubleValue();
			Assert.assertTrue(d == -0.7);
		} catch (ParseException e) {
			Assert.assertTrue(false);
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	@After
	public void tearDown(){
		
	}
	
	
}
